import { useState } from 'react';

import { Button } from 'antd';
import dataSource from '@/datasource.js';
import useChange from '@/views/function/use-change.js';

function Article(props){

    const [version,setVersion] = useState(0);

    const data = useChange( ds => ds.getBlogPost( props.id ) );

    const { title , desc , id }= data;

    const change = () => {
        dataSource.setBlogPost( id );
        setVersion( version + 1 );
    }

    return (
        <div className="blog-post">
            <h3>{ title }</h3>
            <p>{ desc }</p>
            <Button type="primary" onClick={ change }>修改</Button>
        </div>
    )
}

export default Article ;